a5_expand_json Function

Syntax

C result = a5_expand_json(jsonData as C, map as C)

Arguments

jsonDataCharacter

Compact JSON data.

mapCharacter

Defines the field names for the data.

Description

Combines field mappings and JSON data into a single JSON string.

Example

dim data as c =<<%json%
[
	{
		"a": "ALFKI",
		"b": "Maria Anders",
		"c": "Obere Str. 57",
		"d": "Berlin",
		"e": "Germany"
	},
	{
		"a": "ANATR",
		"b": "Ana Trujillo",
		"c": "Avda. de la Constitución 2222",
		"d": "México D.F.",
		"e": "Mexico"
	},
	{
		"a": "ANTON",
		"b": "Antonio Moreno",
		"c": "Mataderos  2312",
		"d": "México D.F.",
		"e": "Mexico"
	},
	{
		"a": "AROUT",
		"b": "Thomas Hardy",
		"c": "120 Hanover Sq.",
		"d": "London",
		"e": "UK"
	},
	{
		"a": "BERGS",
		"b": "Christina Berglund",
		"c": "Berguvsvägen  8",
		"d": "Luleå",
		"e": "Sweden"
	}
]
%json%

dim map as c =<<%str%
{
	"a": "CustomerID",
	"b": "ContactName",
	"c": "Address",
	"d": "City",
	"e": "Country"
}
%str%

? a5_expand_json(data,map)
= [{"CustomerID":"ALFKI","ContactName":"Maria Anders","Address":"Obere Str. 57","City":"Berlin","Country":"Germany"},{"CustomerID":"ANATR","ContactName":"Ana Trujillo","Address":"Avda. de la Constitución 2222","City":"México D.F.","Country":"Mexico"},{"CustomerID":"ANTON","ContactName":"Antonio Moreno","Address":"Mataderos  2312","City":"México D.F.","Country":"Mexico"},{"CustomerID":"AROUT","ContactName":"Thomas Hardy","Address":"120 Hanover Sq.","City":"London","Country":"UK"},{"CustomerID":"BERGS","ContactName":"Christina Berglund","Address":"Berguvsvägen  8","City":"Luleå","Country":"Sweden"}]